// Copyright (c) 2019 Presto Labs Pte. Ltd.
// Author: linchuan

#include "coin2/exchange/kraken/symbology/currency.h"

#include <gtest/gtest.h>

TEST(KrakenCurrency, constructor) {
  using namespace coin2::exchange::kraken::symbology;
  using coin2::exchange::base::market::ExchangeType;
  using coin2::exchange::base::market::MarketType;

  int64_t resolve_ts = 1572502253 * 1e9;

  KrakenCurrency usdt("USDT");
  EXPECT_EQ(usdt.currency(), "USDT");
  EXPECT_EQ(usdt.native_currency(MarketType::Spot), "USDT");
  EXPECT_EQ(usdt.rep_currency(), "USD");
  EXPECT_EQ(usdt.exchange(), ExchangeType::Kraken);

  auto btc1 = KrakenCurrency::FromNativeStr("XXBT", resolve_ts);
  EXPECT_EQ(btc1.currency(), "BTC");
  EXPECT_EQ(btc1.native_currency(MarketType::Spot), "XXBT");
  EXPECT_EQ(btc1.native_currency(MarketType::Futures), "XXBT");
  EXPECT_EQ(btc1.exchange(), ExchangeType::Kraken);

  auto btc3 = KrakenCurrency::FromNormStr("BTC", resolve_ts);
  auto btc4 = KrakenCurrency::FromStr("BTC", resolve_ts);
  EXPECT_EQ(btc3, btc1);
  EXPECT_EQ(btc4, btc1);

  auto btc = KrakenCurrency::FromStr("btc", resolve_ts);
  EXPECT_EQ(btc.currency(), "BTC");
  EXPECT_EQ(btc.native_currency(MarketType::Spot), "XXBT");

  auto bch = KrakenCurrency::FromStr("BCH", resolve_ts);
  EXPECT_EQ(bch.currency(), "BCHABC");
  EXPECT_EQ(bch.native_currency(MarketType::Spot), "BCH");
}
